package Game;

import java.awt.Graphics;
import java.util.ArrayList;

import Game.ManagerSound.Type;


public class EnemyManagerGradius{
	
	public static ArrayList<EnemyGradius> recs;
	
	static int velX;
	public static int inimigosMortos;

	//ID = Cena Atual.
	public static void Setup(int quantColunas, int quantLinhas, int ID, int velX)
	{
		recs = new ArrayList<EnemyGradius>();
		
		EnemyManagerGradius.velX = -velX;
		
		for(int i = 0; i < quantLinhas; i++)
		{
			for(int j = 0; j < quantColunas; j++)
			{
				EnemyGradius temp = new EnemyGradius(j + 60 + (j * 45), 20 + i * 40 + i, 40, 40 ,ID ,5 ,5);
				
				recs.add(temp);
			}
		}		
	}	

	
	public static  void Update(ArrayList<Ball> ball)
	{
		
		for(int i = 0; i < recs.size(); i++)
		{			
			for(int j = 0; j < ball.size(); j++)
			{
				if(recs.get(i).Collision(ball.get(j)))
				{
					inimigosMortos++;
					ball.remove(j);
					recs.remove(i);
					ManagerSound.getIntance().Play(Type.COLLISION);
					break;
				}
			}	
			recs.get(i).y += velX;
		}
	}
	
	public static void Draw(Graphics g)
	{
		for(int i = 0; i < recs.size(); i++)
		{
			recs.get(i).Draw(g);
		}
	}
	
}
	